import sys
import re
def countwords(filename):
    try:
        with open(filename,'r',encoding='utf-8') as f:
            txt=f.read()
            cleaned_txt=re.sub(r'[^a-z\s]',' ',txt.lower())
            txt1=cleaned_txt.split()
            lens=len(txt1)
            return lens
    except Exception as e:
        print(e)
        return 0
if countwords(sys.argv[1]) == 0:
    exit()
with open(sys.argv[2],'w',encoding='utf-8') as qu:
    qu.write(f"总字数为：{countwords(sys.argv[1])}\n")